﻿package com.badibadi.activity;

import java.io.File;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import us.pinguo.edit.sdk.PGEditActivity;
import us.pinguo.edit.sdk.base.PGEditResult;
import us.pinguo.edit.sdk.base.PGEditSDK;

import com.badibadi.adapter.AddingRecordNewAdapter;
import com.badibadi.adapter.AlbumAdapter;
import com.badibadi.infos.AllPhoto_Model;
import com.badibadi.infos.BrowseAllPhoto_Model;
import com.badibadi.infos.Discuss;
import com.badibadi.infos.ImgAuthority;
import com.badibadi.infos.ImgInfoModel;
import com.badibadi.infos.ImgShowModel;
import com.badibadi.infos.Pre_message_total;
import com.badibadi.infos.Results;
import com.badibadi.infos.User;
import com.badibadi.mytools.BitmapHelp;
import com.badibadi.mytools.CommonUtils;
import com.badibadi.mytools.Constants;
import com.badibadi.mytools.Dialog;
import com.badibadi.mytools.JSONUtils;
import com.badibadi.mytools.MyThreadTool;
import com.badibadi.mytools.ShareSDKTools;
import com.badibadi.mytools.Utils;
import com.badibadi.uniclubber.R;
import com.badibadi.uniclubber.R.menu;
import com.libjph.util.JsonUtil;
import com.libjph.util.StringUtil;
//import com.lidroid.xutils.util.LogUtils;
import com.nostra13.universalimageloader.core.DisplayImageOptions;
import com.nostra13.universalimageloader.core.ImageLoader;
import com.nostra13.universalimageloader.core.assist.FailReason;
import com.nostra13.universalimageloader.core.assist.ImageScaleType;
import com.nostra13.universalimageloader.core.display.RoundedBitmapDisplayer;

import android.os.Bundle;
import android.os.Environment;
import android.os.Handler;
import android.os.Message;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.ColorFilter;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.support.v4.view.PagerAdapter;
import android.support.v4.view.ViewPager;
import android.util.Log;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.PopupWindow;
import android.widget.ScrollView;
import android.widget.TextView;
import android.widget.Toast;

/**
 * 足迹成功 iv_share l_pinglun userHead Constants .setOn holder.zan Intent bianji
 * userHead intent.putExtra("picture_list",(Serializable) allPhoto_Models); set
 * participants Contents intent.putExtra("picture_postion", arg2); onstart share
 * 
 * @author Administrator Constants user_dream
 * 
 *         participants l_pinglun title
 * 
 */
public class PicturePreviewActivity extends BaseActivity implements
		OnClickListener {
	protected static final String TAG = "PicturePreviewActivity";

	public static final int REFRESH = 8080;
	// （上一个界面）传过来的数据 两条
	List<BrowseAllPhoto_Model> AllPhoto_Models; // 这里的数据用的到两条，一个是图片id，一个是path路径
	int picture_postion;

	private ImageView pop_btn;
	private PopupWindow pop1;
	View root;
	private ViewPager viewPager;
	/** 显示图片的数量 */
	private TextView pic_num_zhishi;
	/** 显示的哪一张 */
	private int num_show;
	/** 总张数 */
	private int num_zong;
	private List<View> views;
	/** 评论按钮 */
	private LinearLayout l_pinglun;

	// 需要传过来的数据
	private String imgId = "1";
	// 用户id
	private String uid = "1";

	private ImgShowModel imgShowModel;
	Results results;
	Results results2;// 足迹梦想和收藏某张照片的文字按钮
	Results results3;// 看某张照片的参与者

	List<User> user;// 看参与者需要的数据
	// 下面是评论的
	private Discuss discuss;
	ViewHolder holder;
	private DisplayImageOptions options;

	// 权限的接口
	ImgAuthority imgAuthority;
	private Handler handler = new Handler() {
		@Override
		public void handleMessage(Message msg) {
			switch (msg.what) {
			case 1:
				Utils.ExitPrgress(PicturePreviewActivity.this);
				try {
					Utils.showMessage(PicturePreviewActivity.this,
							getResources().getString(R.string.l_net_error));
				} catch (Exception e) {

				}
				break;
			case 2:// 标签更新
				Utils.ExitPrgress(PicturePreviewActivity.this);

				break;
			case 3:
				Utils.ExitPrgress(PicturePreviewActivity.this);
				try {
					Utils.showMessage(PicturePreviewActivity.this,
							getResources().getString(R.string.SystemError));
				} catch (Exception e) {
					// TODO: handle exception
				}

				break;
			// case 4:// 这是评论的
			// Utils.ExitPrgress(PicturePreviewActivity.this);
			// try {
			// pinglunPopWindow();
			// // praiseList("photo_img",imgShowModel.getId());
			// } catch (Exception e) {
			// // TODO: handle exception
			// }
			// break;
			case 5:
				Utils.ExitPrgress(PicturePreviewActivity.this);
				try {
					Utils.showMessage(PicturePreviewActivity.this,
							getResources().getString(R.string.SystemError));
				} catch (Exception e) {

				}
				break;
			case 6:// 获取数据完成后
				try {
					initView();
				} catch (Exception e) {
					// TODO: handle exception
				}
				Utils.ExitPrgress(PicturePreviewActivity.this);
				break;
			case 7:// 足迹和梦想和收藏成功后
				Utils.ExitPrgress(PicturePreviewActivity.this);
				try {
					if (results2.isRet() == true) {
						Constants.is_shuaxin = true;
						String t = msg.getData().getString("type");
						if (t.equals("a1")) {
							Utils.showMessage(PicturePreviewActivity.this,
									getResources().getString(R.string.wx2_37));
							holder.user_footmark.setTextColor(getResources()
									.getColor(R.color.blue));
							// user_footmark=(TextView)PicturePreviewActivity.this.findViewById(R.id.user_footmark);
							// user_collect=(TextView)PicturePreviewActivity.this.findViewById(R.id.user_collect);
							// user_dream=(TextView)PicturePreviewActivity.this.findViewById(R.id.user_dream);
						} else if (t.equals("a2")) {
							Utils.showMessage(PicturePreviewActivity.this,
									getResources().getString(R.string.l_xb116));
							holder.user_dream.setTextColor(getResources()
									.getColor(R.color.blue));
						} else if (t.equals("a3")) {
							Utils.showMessage(PicturePreviewActivity.this,
									getResources().getString(R.string.l_xb117));
							holder.user_collect.setTextColor(getResources()
									.getColor(R.color.blue));
						}

					}

				} catch (Exception e) {
					// TODO: handle exception
				}
				break;
			case 8:// 看参与者的数量
				try {
					if (user != null) {

						((TextView) (PicturePreviewActivity.this
								.findViewById(R.id.participants_number)))
								.setText("(" + user.size() + ")");

					}
				} catch (Exception e) {
					// TODO: handle exception

				}

				break;
			// case 9:// 评论成功
			// Utils.ExitPrgress(PicturePreviewActivity.this);
			// try {
			// Utils.showMessage(PicturePreviewActivity.this, "评论成功");
			//
			// gengxinPinLun();
			// initDissCussView();
			//
			// } catch (Exception e) {
			//
			// }
			//
			// break;
			case 10:// 评论失败
				Utils.ExitPrgress(PicturePreviewActivity.this);
				try {
					Utils.showMessage(PicturePreviewActivity.this,
							getResources().getString(R.string.l_xb113));
				} catch (Exception e) {
					// TODO: handle exception
				}

				break;
			case 11:// 更新参加者列表
				Utils.ExitPrgress(PicturePreviewActivity.this);
				try {
					// gengxinPraiseList();
				} catch (Exception e) {
					// TODO: handle exception
				}

				break;

			case 12:// 删除成功
				Utils.ExitPrgress(PicturePreviewActivity.this);
				try {
					Utils.showMessage(PicturePreviewActivity.this,
							getResources().getString(R.string.l_xb55));
					AllPhoto_Models.remove(num_show - 1);
					if (AllPhoto_Models.size() >= 1) {
						Intent intent = new Intent(PicturePreviewActivity.this,
								PicturePreviewActivity.class);
						intent.putExtra("picture_list",
								(Serializable) AllPhoto_Models);
						intent.putExtra("picture_postion", 0);
						startActivity(intent);
						Constants.is_shuaxin = true;
						PicturePreviewActivity.this.finish();

						overridePendingTransition(R.anim.slide_left,
								R.anim.slide_right);
					} else if (AllPhoto_Models.size() == 0) {
						Constants.is_shuaxin = true;
						PicturePreviewActivity.this.finish();

						overridePendingTransition(R.anim.slide_left,
								R.anim.slide_right);
					}
					// gengxinPraiseList();
				} catch (Exception e) {
					// TODO: handle exception
				}

				break;
			case 13:// 删除shibai
				Utils.ExitPrgress(PicturePreviewActivity.this);
				try {
					// gengxinPraiseList();
					Utils.showMessage(PicturePreviewActivity.this,
							getResources().getString(R.string.l_xb118));

				} catch (Exception e) {
					// TODO: handle exception
				}
			case 14:// 操作成功
				Utils.ExitPrgress(PicturePreviewActivity.this);
				try {
					// gengxinPraiseList();
					Utils.showMessage(PicturePreviewActivity.this,
							getResources().getString(R.string.l_xb55));
					Resh(imgShowModel.getId());
				} catch (Exception e) {
					// TODO: handle exception
				}
				break;
			case 15:// 操作失败
				Utils.ExitPrgress(PicturePreviewActivity.this);
				try {
					// gengxinPraiseList();
					Utils.showMessage(PicturePreviewActivity.this,
							getResources().getString(R.string.l_xb113));

				} catch (Exception e) {
					// TODO: handle exception
				}
				break;
			case 16:// 权限问题
				Utils.ExitPrgress(PicturePreviewActivity.this);
				try {
					// gengxinPraiseList();

					String quanxian = msg.getData().getString("msg");
					showSettingPic(quanxian);
				} catch (Exception e) {
					// TODO: handle exception
				}
				break;
			case 17:// //权限问题
				Utils.ExitPrgress(PicturePreviewActivity.this);
				try {
					// gengxinPraiseList();
					Utils.showMessage(PicturePreviewActivity.this,
							getResources().getString(R.string.l_xb113));

				} catch (Exception e) {
					// TODO: handle exception
				}
			default:
				break;
			}
		}

	};

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		goToTheTitle();

		setContentView(R.layout.picture_preview);
		Constants.is_shuaxin = false;

		options = new DisplayImageOptions.Builder()
				.showStubImage(R.drawable.ic_stub)
				.showImageForEmptyUri(R.drawable.noimage)
				.showImageOnFail(R.drawable.noimage)
				.imageScaleType(ImageScaleType.EXACTLY)
				.bitmapConfig(Bitmap.Config.RGB_565).cacheOnDisc()
				.displayer(new RoundedBitmapDisplayer(0)).build();

		/**
		 * intent.putExtra("picture_list",(Serializable) allPhoto_Models);
		 * intent.putExtra("picture_postion", arg2);
		 * 
		 * @author Administrator
		 * 
		 */
		AllPhoto_Models = (List<BrowseAllPhoto_Model>) getIntent()
				.getSerializableExtra("picture_list");

		picture_postion = getIntent().getIntExtra("picture_postion", 0);
		// Log.v("sss1", "数据:" + AllPhoto_Models.toString());
		init();
		try {
			Resh(AllPhoto_Models.get(picture_postion).getId());
		} catch (Exception e) {
			// TODO: handle exception
		}
	}

	/**
	 * 刷新图片信息
	 */
	public void Resh(String imgid) {
		((TextView) (PicturePreviewActivity.this
				.findViewById(R.id.participants_number)))
				.setText("(" + 0 + ")");
		// 1照片参与者
		participator(imgid);
		// 2这是显示图片的信息
		imgShow(imgid);
	}

	public class ViewHolder {
		public String id; // 图片ID
		public TextView title; // 图片名称
		public String uid; // 图片用户ID
		public String path; // 图片路径
		public String attachment; // 图片来源
		public String info; // 图片介绍
		public String photo_id; // 图片相册ID
		public String club_id; // 图片所属俱乐部ID
		public String activity_id; // 图片所属活动ID
		public TextView view; // 图片足迹数
		public TextView dream; // 图片梦想数
		public TextView collect; // 图片收藏数
		public TextView admire; // 图片赞赏数
		public TextView discuss; // 图片评论数
		public TextView share; // 图片分享数
		public TextView address; // 图片地址
		public String photoImgNum; // 图片所属相册含有的图片总数
		public String imgNum; // 该图片在所属相册中属于第几张图片
		public TextView user_footmark; // 该用户是否足迹该图片
		public TextView user_dream; // 该用户是否梦想该图片
		public TextView user_collect; // 该用户是否收藏该图片
		public ImageView userHead; // 发布该图片的用户头像
		ImageView iv_share;
		public LinearLayout zan;

		public ViewHolder() {
			title = (TextView) PicturePreviewActivity.this
					.findViewById(R.id.title);
			address = (TextView) PicturePreviewActivity.this
					.findViewById(R.id.address);
			admire = (TextView) PicturePreviewActivity.this
					.findViewById(R.id.admire);
			discuss = (TextView) PicturePreviewActivity.this
					.findViewById(R.id.discuss);
			share = (TextView) PicturePreviewActivity.this
					.findViewById(R.id.share);
			userHead = (ImageView) PicturePreviewActivity.this
					.findViewById(R.id.userHead);
			user_footmark = (TextView) PicturePreviewActivity.this
					.findViewById(R.id.user_footmark);
			user_collect = (TextView) PicturePreviewActivity.this
					.findViewById(R.id.user_collect);
			user_dream = (TextView) PicturePreviewActivity.this
					.findViewById(R.id.user_dream);
			zan = (LinearLayout) PicturePreviewActivity.this
					.findViewById(R.id.zan);
			iv_share = (ImageView) PicturePreviewActivity.this
					.findViewById(R.id.iv_share);
		}
	}

	private void initView() {
		holder = new ViewHolder();
		holder.iv_share.setOnClickListener(new View.OnClickListener() {

			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				if (!StringUtil.isNullOrEmpty(imgShowModel.getPath())) {
					ShareSDKTools.ShowOneKeyShare(
							PicturePreviewActivity.this,
							"分享",
							imgShowModel.getTitle(),
							"",
							Constants.BadiDownImgUrl + "/"
									+ imgShowModel.getPath(), null,
							imgShowModel.getId(), imgShowModel.getUid(),
							imgShowModel.getClub_id(), "photo_img");
				} else {
					ShareSDKTools.ShowOneKeyShare(PicturePreviewActivity.this,
							"分享", imgShowModel.getTitle(), "", "", null,
							imgShowModel.getId(), imgShowModel.getUid(),
							imgShowModel.getClub_id(), "photo_img");
				}

			}
		});
		// * @param context
		// * 上下文
		// * @param title(标签)
		// * @param text（内容）
		// * @param titleUrl
		// * (不传)
		// * @param ImageUrl
		// * 下面是 站内分享要传的
		// * @param type
		// * 分享类型 心情动态：humor_trends 活动：activity 俱乐部：club
		// *
		// * @param $share_id
		// * 被分享的内容ID（心情动态ID 或 活动ID 或 俱乐部ID）
		// * @param $dul
		// * 分享谁的心情动态、活动、俱乐部-------发布被分享的动态原始数据的用户ID
		// * @param $cid
		// * 俱乐部ID---该参数只在俱乐部动态中才有非0值，对于个人中心动态中的$cid=0
		// *
		// * 站外分享返回相应链接----POST
		// * @param $type2 分享类型 photo_img：相片 humor_trends:心情动态
		// record_article：记录（记） club:创建的俱乐部 activity：发起的活动 friend：朋友
		// *
		holder.title.setText(imgShowModel.getTitle());
		holder.address.setText("" + imgShowModel.getAddress());
		try {
			ImageLoader.getInstance().displayImage(
					Constants.BadiDownImgUrl + "/" + imgShowModel.getUserHead()
							+ Constants.appPhoto4img, holder.userHead, options);
		} catch (Exception e) {
			// TODO: handle exception
		}
		holder.userHead.setOnClickListener(new View.OnClickListener() {

			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				if (imgShowModel != null) {
					if (Utils.getUid(PicturePreviewActivity.this).equals(
							"" + imgShowModel.getUid())) {
						Intent intent = new Intent(PicturePreviewActivity.this,
								MyDataActivity.class);
						startActivity(intent);
					} else {
						Intent intent = new Intent(PicturePreviewActivity.this,
								SeeOtherPeopleSpaceActivity.class);
						intent.putExtra("friend_id", imgShowModel.getUid());
						startActivity(intent);
					}
				}

			}
		});
		holder.admire.setText("(" + imgShowModel.getAdmire() + ")");
		holder.discuss.setText("(" + imgShowModel.getDiscuss() + ")");
		if (!StringUtil.isNullOrEmpty(imgShowModel.getshare())) {
			holder.share.setText("(" + imgShowModel.getshare() + ")");
		} else {
			holder.share.setText("(0)");
		}

		// 是否足迹过
		if (imgShowModel.getUser_footmark().equals("1")) {
			holder.user_footmark.setTextColor(getResources().getColor(
					R.color.blue));
		} else {
			holder.user_footmark.setTextColor(getResources().getColor(
					R.color.f_white));
			holder.user_footmark.setOnClickListener(new View.OnClickListener() {

				@Override
				public void onClick(View v) {
					// TODO Auto-generated method stub
					ImgStatus(imgShowModel.getId(), "a1");
				}
			});
		}
		// 梦想
		if (imgShowModel.getUser_dream().equals("1")) {
			holder.user_dream.setTextColor(getResources()
					.getColor(R.color.blue));
		} else {
			holder.user_dream.setTextColor(getResources().getColor(
					R.color.f_white));
			holder.user_dream.setOnClickListener(new View.OnClickListener() {

				@Override
				public void onClick(View v) {
					// TODO Auto-generated method stub
					ImgStatus(imgShowModel.getId(), "a2");
				}
			});
		}
		// 收藏
		if (imgShowModel.getUser_collect().equals("1")) {
			holder.user_collect.setTextColor(getResources().getColor(
					R.color.blue));
		} else {
			holder.user_collect.setTextColor(getResources().getColor(
					R.color.f_white));
			holder.user_collect.setOnClickListener(new View.OnClickListener() {

				@Override
				public void onClick(View v) {
					// TODO Auto-generated method stub
					ImgStatus(imgShowModel.getId(), "a3");
				}
			});
		}
		// 赞
		holder.zan.setOnClickListener(new View.OnClickListener() {

			@Override
			public void onClick(View v) {
				dianzan(PicturePreviewActivity.this, uid, imgShowModel.getId(),
						imgShowModel.getUid(), "photo_img");
			}
		});
		// tupiansettingPopWindow();sdf
		gengxinPinLun();// 更新评论
		// praiseList();
	}

	// 更新参加的人

	private void gengxinPraiseList() {
		// TODO Auto-generated method stub

	}

	/*
	 * 用户赞列表---POST
	 * 
	 * @param $type 赞的类型 humor_trends：心情动态 photo：相册 photo_img：图片
	 * record_article：记录（记） activity：活动 club：俱乐部
	 * 
	 * @param $contentId 被赞的内容ID
	 */
	private void praiseList(final String type, final String contentId) {
		// TODO Auto-generated method stub
		MyThreadTool.fixedThreadPool.execute(new Runnable() {
			@Override
			public void run() {
				// list= new ArrayList<Pre_message_total>();
				// String content = Utils.getRequest(Constants.BadiUrl_1+
				// "photo/imgInfo?imgId="+imgId+"&languageType="+languageType);
				Map<String, Object> map = new HashMap<String, Object>();
				map.put("type", type);
				map.put("contentId", contentId);
				String content = Utils.sendRequest(map, Constants.BadiUrl_1
						+ "commonality/praiseList");
				// Log.v(TAG,""+invite_content);
				if (content != null) {
					Results results2 = Utils.checkResult_NNN(
							PicturePreviewActivity.this, content);
					if (results2 != null
							&& !results2.getRetmsg().equals("null")) {
						// Log.i(TAG, "更新参加者的数据是:" + results.getRetmsg());
						try {

							// imgShowModel =
							// JSONUtils.getEntityByJsonString(results.getRetmsg(),
							// ImgShowModel.class);

							Message msg = new Message();
							msg.what = 11;
							handler.sendMessage(msg);
						} catch (Exception e) {
							// TODO Auto-generated catch block
							e.printStackTrace();
						}
					} else {

						// handler.sendEmptyMessage(3);
					}
				} else {

					// handler.sendEmptyMessage(1);
				}

			}
		});
	}

	private void init() {
		// TODO Auto-generated method stub

		/**
		 * 进入到看参与者
		 */
		this.findViewById(R.id.participants).setOnClickListener(
				new View.OnClickListener() {

					@Override
					public void onClick(View v) {
						// TODO Auto-generated method stub
						// 跳转到看参与者
						if (imgShowModel != null) {
							Intent intent = new Intent(
									PicturePreviewActivity.this,
									PinyinSeePicParticipantsActivity.class);
							intent.putExtra("imgId", imgShowModel.getId());
							startActivity(intent);
						}

					}
				});

		views = new ArrayList<View>();
		pop_btn = (ImageView) this.findViewById(R.id.pop_btn);
		pop_btn.setOnClickListener(this);
		viewPager = (ViewPager) this.findViewById(R.id.tabpager);
		pic_num_zhishi = (TextView) this.findViewById(R.id.pic_num_zhishi);
		l_pinglun = (LinearLayout) this.findViewById(R.id.l_pinglun);
		l_pinglun.setOnClickListener(this);
		MyPagerAdapter adapter = new MyPagerAdapter(AllPhoto_Models);
		viewPager.setAdapter(adapter);
		// 显示要显示的界面
		viewPager.setCurrentItem(picture_postion);
		// 张数显示为1
		num_show = picture_postion + 1;
		// 预先加载的页数
		viewPager.setOffscreenPageLimit(1);
		viewPager.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {

			@Override
			public void onPageSelected(int pos) {
				// TODO Auto-generated method stub
				// 下面两句用于显示 （？/3）
				num_show = pos + 1;
				showPicNumber();
				// imgShow(AllPhoto_Models.get(pos).getId());
				// participator(AllPhoto_Models.get(pos).getId());
				Resh(AllPhoto_Models.get(pos).getId());

			}

			@Override
			public void onPageScrolled(int arg0, float arg1, int arg2) {
				// TODO Auto-generated method stub
				// Log.v(TAG, "onPageScrolled");
			}

			@Override
			public void onPageScrollStateChanged(int arg0) {
				// TODO Auto-generated method stub
				// Log.v(TAG, "onPageScrollStateChanged");
			}
		});

		showPicNumber();

	}

	// 从网络上获取评论的数据
	public void gengxinPinLun() {
		/**
		 * 查看某个动态的评论列表---get(必需--配合语言)
		 * 
		 * @param $id
		 *            //(必需)需要查看的动态评论ID
		 * @param $type
		 *            //(必需)动态的类型---photo_img：图片，photo：相册，record_article：记录（记），
		 *            humor_trends:心情动态，club：俱乐部，activity：活动
		 * @param $disNum
		 *            //显示的一级评论数量
		 * @param $l
		 *            ;（必需）//zh-cn 为中文简体，zh-tw 中文繁体 en-us 英文
		 */
		ShowDisscuss(imgShowModel.getId(), "photo_img", "" + 99999999,
				Dialog.getSystemLanguageTypegy(PicturePreviewActivity.this));
	}

	/** 右上角编辑图片的popwindows */
	private void tupiansettingPopWindow(String quanxian) {
		// 0：举报
		// 1：删除+编辑
		String type = quanxian;
		// TODO Auto-generated method stub
		View root = this.getLayoutInflater().inflate(
				R.layout.picture_preview_popwindow1, null);
		// 删除这张图片 close_pop

		root.findViewById(R.id.close_pop).setOnClickListener(
				new View.OnClickListener() {

					@Override
					public void onClick(View v) {
						// TODO Auto-generated method stub
						if (pop1 != null) {
							pop1.dismiss();
							pop1 = null;
						}
					}
				});
		if (type.equals("1")) {
			root.findViewById(R.id.jubao).setVisibility(View.GONE);
		} else {
			root.findViewById(R.id.bianji).setVisibility(View.GONE);
			root.findViewById(R.id.delete).setVisibility(View.GONE);
		}

		root.findViewById(R.id.delete).setOnClickListener(
				new View.OnClickListener() {

					@Override
					public void onClick(View v) {
						// TODO Auto-generated method stub
						Dialog d = new com.badibadi.mytools.Dialog();
						d.CreateDialog(PicturePreviewActivity.this,
								getResources().getString(R.string.Delete),
								getResources().getString(R.string.l_xb48));
						d.setOnDialogClistener(new Dialog.DialogClistener() {

							@Override
							public void ret() {

							}

							@Override
							public void ok() {
								Constants.is_shuaxin = true;
								delImg("" + imgShowModel.getId());
							}
						});

					}
				});
		root.findViewById(R.id.bianji).setOnClickListener(this);
		root.findViewById(R.id.meituxiuxiu).setOnClickListener(this);
		root.findViewById(R.id.jubao).setOnClickListener(this);
		LinearLayout pop_win = (LinearLayout) root.findViewById(R.id.pop_win);
		int h = getKH(pop_win, false) + 100;
		// Log.v("aaa", "hh===>" + h);
		pop1 = new PopupWindow(root, (int) getScreenSize(SCREENW), h);
		pop1.setBackgroundDrawable(new BitmapDrawable());
		pop1.setFocusable(true);
		pop1.setTouchable(true);
		pop1.setOutsideTouchable(true);
	}

	/**
	 * 删除单张照片的接口
	 */
	protected void delImg(String imgId) {
		// TODO Auto-generated method stub
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("uid", Utils.getUid(PicturePreviewActivity.this));
		map.put("imgId", imgId);
		CommonUtils.CommomPostfunction(PicturePreviewActivity.this,
				Constants.BadiUrl_1 + "/" + "Image/delImg", map, handler, 1, 3,
				12, 13);
	}

	/**
	 * 关闭图片设置的悬浮对话框
	 */
	private void CloseTupianSettingPopwindow() {

		if (pop1 != null) {
			pop1.dismiss();
			pop1 = null;
		}

	}

	// /**
	// * 关闭评论的悬浮对话框
	// */
	// private void ClosePinglunPopwindow() {
	//
	// pop.dismiss();
	//
	// }

	@Override
	protected void onStart() {
		// TODO Auto-generated method stub
		super.onStart();
		try {
			if (Constants.is_shuaxin_picturePreview == true) {
				init();
				Constants.is_shuaxin_picturePreview = false;
				if (imgShowModel != null) {
					Resh(imgShowModel.getId());
				}

			}
		} catch (Exception e) {
			// TODO: handle exception
		}

	}

	private void showPicNumber() {
		// TODO Auto-generated method stub
		// Log.v(TAG, "onPageSelected");
		pic_num_zhishi.setText(num_show + "/" + num_zong);
	}

	@Override
	public void onClick(View v) {
		// TODO Auto-generated method stub
		switch (v.getId()) {
		case R.id.pop_btn:// 点击设置
			if (imgShowModel != null) {
				getBianjiQuanXian(imgShowModel.getId());
			}
			break;
		case R.id.l_pinglun:// 点击评论
			// initDissCussView();
			if (imgShowModel != null) {
				Intent inten = new Intent(PicturePreviewActivity.this,
						PicturePinLunActivity.class);
				inten.putExtra("imgShowModel", imgShowModel);
				startActivityForResult(inten, 1);
			}

			break;
		case R.id.meituxiuxiu:// 点击美图秀秀
			OpenTheThirdPartySoftWare(MEITUXIUXIU_PAGENAME, MEITUXIUXIU_Uri);
			break;
		case R.id.close_pop:
			CloseTupianSettingPopwindow();
			break;
		case R.id.bianji:
			// if (imgShowModel.getUid() != null) {
			// if (imgShowModel.getUid().equals(
			// Utils.getUid(PicturePreviewActivity.this))) {

			Intent intent = new Intent(this,
					ModifiedImageInformationActivity.class);

			intent.putExtra("imgId", imgShowModel.getId());
			System.out.println("imgId" + imgShowModel.getId());
			System.out.println("imgId" + AllPhoto_Models.get(0).getPath());
			startActivity(intent);

			// String folderPath =
			// Environment.getExternalStoragePublicDirectory(
			// Environment.DIRECTORY_DCIM).getAbsolutePath()
			// + File.separator;
			// System.out.println("folderPath" + folderPath);
			// String outFilePath = folderPath + System.currentTimeMillis()
			// + ".jpg";
			// System.out.println("outFilePath" + outFilePath);
			// PGEditSDK.instance().startEdit(PicturePreviewActivity.this,
			// PGEditActivity.class,"photo.uniclubber.com/"
			// +AllPhoto_Models.get(0).getPath(),
			// outFilePath);

			CloseTupianSettingPopwindow();
			// } else {
			// Utils.showMessage(PicturePreviewActivity.this,
			// getResources().getString(R.string.l_xb121));
			// }
			// } else {
			// Utils.showMessage(PicturePreviewActivity.this, getResources()
			// .getString(R.string.l_xb121));
			// }

			break;
		case R.id.jubao:
			// if (imgShowModel.getUid().equals(
			// Utils.getUid(PicturePreviewActivity.this))) {
			// Utils.showMessage(PicturePreviewActivity.this, getResources()
			// .getString(R.string.l_xb122));
			// } else { //
			// (必需)举报的类型（humor_trends：心情动态，photo：相册，record：记录（篇），record_article：记录（记），activity：活动，club：俱乐部，discuss：评论）
			Intent intent2 = new Intent(this, InformActivity.class);
			String table = "photo";
			intent2.putExtra("table", table);
			intent2.putExtra("bei_person_id", imgShowModel.getUid());
			intent2.putExtra("bei_neirong_id", imgShowModel.getId());
			intent2.putExtra("bei_cid", "0");
			startActivity(intent2);
			// }
			break;
		// case R.id.user_footmark://足迹
		// ImgStatus(imgid, type);
		// break;
		//
		// case R.id.user_dream://梦想
		// break;
		// case R.id.user_collect://收藏
		// break;
		}
	}

	private void showSettingPic(String quanxian) {

		tupiansettingPopWindow(quanxian);
		pop1.showAtLocation(findViewById(R.id.show), Gravity.BOTTOM, 0, 0);
	}

	/**
	 * 适配器
	 * 
	 * @author Administrator
	 * 
	 */
	class MyPagerAdapter extends PagerAdapter {

		// int[] pic = { R.drawable.zhaopian, R.drawable.noimage,
		// R.drawable.add2_select };
		List<BrowseAllPhoto_Model> allPhoto_Models;

		public MyPagerAdapter(List<BrowseAllPhoto_Model> allPhoto_Models) {
			LayoutInflater inflater = LayoutInflater
					.from(PicturePreviewActivity.this);
			this.allPhoto_Models = allPhoto_Models;
			num_zong = allPhoto_Models.size();

			for (int i = 0; i < allPhoto_Models.size(); i++) {
				View view = inflater.inflate(
						R.layout.picture_preview_adapter_import_layout, null);
				// ImageView iv = (ImageView) view
				// .findViewById(R.id.pic_imageView1);
				// ImageLoader.getInstance().displayImage(Constants.BadiDownImgUrl+"/"+allPhoto_Models,
				// iv, options);
				// ImageLoader.getInstance().displayImage(
				// Constants.BadiDownImgUrl + "/"
				// + allPhoto_Models.get(i).getPath()
				// + Constants.appBGimg, iv, options);
				// LogUtils.d(""+Constants.BadiDownImgUrl + "/"
				// + allPhoto_Models.get(i).getPath()
				// + Constants.appBGimg);
				views.add(view);
			}
		}

		/** 这里返回一个view */
		@Override
		public Object instantiateItem(ViewGroup container, int position) {
			View view = views.get(position);
			ImageView iv = (ImageView) view.findViewById(R.id.pic_imageView1);

			// ImageLoader.getInstance().clearDiscCache();
			// ImageLoader.getInstance().displayImage(
			// Constants.BadiDownImgUrl + "/"
			// + allPhoto_Models.get(position).getPath()
			// + Constants.appBGimg, iv, options,new
			// SimpleImageLoadingListener(){
			// @Override
			// public void onLoadingFailed(String imageUri,
			// View view, FailReason failReason) {
			// // TODO Auto-generated method stub
			// String message = null;
			// switch (failReason.getType()) { // 获取图片失败类型
			// case IO_ERROR: // 文件I/O错误
			// message = "Input/Output error";
			// break;
			// case DECODING_ERROR: // 解码错误
			// message = "Image can't be decoded";
			// break;
			// case NETWORK_DENIED: // 网络延迟
			// message = "Downloads are denied";
			// break;
			// case OUT_OF_MEMORY: // 内存不足
			// message = "Out Of Memory error";
			// break;
			// case UNKNOWN: // 原因不明
			// message = "Unknown error";
			// break;
			// }
			//
			// // Toast.makeText(ImagePagerActivity.this, message,
			// Toast.LENGTH_SHORT).show();
			// Utils.showMessage(PicturePreviewActivity.this, message);
			//
			// super.onLoadingFailed(imageUri, view, failReason);
			// }
			// });

			BitmapHelp bitmaphelp = new BitmapHelp();

			// bitmaphelp.getBitmapUtils(PicturePreviewActivity.this).displayImage(iv,
			// Constants.BadiDownImgUrl + "/"
			// + allPhoto_Models.get(position).getPath()
			// + Constants.appBGimg);
			bitmaphelp.displayImage(
					PicturePreviewActivity.this,
					iv,
					Constants.BadiDownImgUrl + "/"
							+ allPhoto_Models.get(position).getPath());

			((ViewPager) container).addView(views.get(position));
			// LogUtils.d("" + "加载了第" + position + "涨》" +
			// Constants.BadiDownImgUrl
			// + "/" + allPhoto_Models.get(position).getPath()
			// + Constants.appBGimg);
			return views.get(position);
		}

		@Override
		public void destroyItem(ViewGroup container, int position, Object object) {
			((ViewPager) container).removeView((View) object);// views.get(position)
			// LogUtils.d("destroyItem");
		}

		@Override
		public int getCount() {
			return views.size();
		}

		@Override
		public boolean isViewFromObject(View arg0, Object arg1) {
			// LogUtils.d("isViewFromObject");
			return arg0 == arg1;
		}

	}

	/**
	 * 图片详细阅读----POST
	 * 
	 * @param $uid
	 *            ;//登录用户的ID 1
	 * @param $imgId
	 *            ;//图片ID 1
	 */
	private void imgShow(final String imgId) {
		// TODO Auto-generated method stub
		// imgInfo
		//
		// Utils.showPrgress(PicturePreviewActivity.this);
		MyThreadTool.fixedThreadPool.execute(new Runnable() {
			@Override
			public void run() {
				// list= new ArrayList<Pre_message_total>();

				String languageType = Dialog
						.getSystemLanguageType(PicturePreviewActivity.this);
				// String content = Utils.getRequest(Constants.BadiUrl_1+
				// "photo/imgInfo?imgId="+imgId+"&languageType="+languageType);

				Map<String, Object> map = new HashMap<String, Object>();
				map.put("uid", Utils.getUid(PicturePreviewActivity.this));
				map.put("imgId", imgId);
				String content = Utils.sendRequest(map, Constants.BadiUrl_1
						+ "Image/imgShow");
				// Log.i(TAG, "打印的数据是:" + map.toString());
				if (content != null) {
					results = Utils.checkResult_NNN(
							PicturePreviewActivity.this, content);
					if (results != null && !results.getRetmsg().equals("null")) {
						// Log.i(TAG, "解析出来的数据:" + results.getRetmsg());
						try {
							imgShowModel = JSONUtils.getEntityByJsonString(
									results.getRetmsg(), ImgShowModel.class);
							handler.sendEmptyMessage(6);
						} catch (Exception e) {
							// TODO Auto-generated catch block
							e.printStackTrace();
						}
					} else {

						handler.sendEmptyMessage(5);
					}
				} else {

					handler.sendEmptyMessage(1);
				}

			}
		});
	}

	/**
	 * 图片足迹、梦想和收藏操作-----POST
	 * 
	 * @param $uid
	 *            ---登录用户ID（主动者ID）
	 * @param $imgid
	 *            -- 被操作的图片ID
	 * @param $type
	 *            -- 足迹：a1 梦想：a2 收藏：a3
	 */
	private void ImgStatus(final String imgid, final String type) {

		MyThreadTool.fixedThreadPool.execute(new Runnable() {
			@Override
			public void run() {
				// list= new ArrayList<Pre_message_total>();
				String languageType = Dialog
						.getSystemLanguageType(PicturePreviewActivity.this);
				// String content = Utils.getRequest(Constants.BadiUrl_1+
				// "photo/imgInfo?imgId="+imgId+"&languageType="+languageType);
				Map<String, Object> map = new HashMap<String, Object>();
				map.put("uid", Utils.getUid(PicturePreviewActivity.this));
				map.put("imgid", imgid);
				map.put("type", type);
				String content = Utils.sendRequest(map, Constants.BadiUrl_1
						+ "Image/imgStatus");
				// Log.v(TAG,""+invite_content);
				if (content != null) {
					results2 = Utils.checkResult_NNN(
							PicturePreviewActivity.this, content);
					if (results2 != null
							&& !results2.getRetmsg().equals("null")) {
						// Log.i(TAG,"解析出来的数据:" + results.getRetmsg());
						try {

							// imgShowModel =
							// JSONUtils.getEntityByJsonString(results.getRetmsg(),
							// ImgShowModel.class);

							Message msg = new Message();
							msg.what = 7;
							Bundle bun = new Bundle();
							bun.putString("type", type);
							msg.setData(bun);
							handler.sendMessage(msg);
						} catch (Exception e) {
							// TODO Auto-generated catch block
							e.printStackTrace();
						}
					} else {

						handler.sendEmptyMessage(3);
					}
				} else {

					handler.sendEmptyMessage(1);
				}

			}
		});

	}

	/**
	 * 获取某张图片的参与者----POST
	 * 
	 * @param $imgId
	 *            //图片ID----测试ID ： 755
	 * 
	 * @param $uid
	 *            //用户ID --- 1
	 */
	private void participator(final String imgid) {

		MyThreadTool.fixedThreadPool.execute(new Runnable() {
			@Override
			public void run() {
				// list= new ArrayList<Pre_message_total>();
				// String
				// languageType=Dialog.getSystemLanguageType(PicturePreviewActivity.this);
				// String content = Utils.getRequest(Constants.BadiUrl_1+
				// "photo/imgInfo?imgId="+imgId+"&languageType="+languageType);
				Map<String, Object> map = new HashMap<String, Object>();
				map.put("imgId", imgid);
				map.put("uid", Utils.getUid(PicturePreviewActivity.this));
				String content = Utils.sendRequest(map, Constants.BadiUrl_1
						+ "photo/participator");
				// Log.v(TAG, "" + content);
				if (content != null) {
					results3 = Utils.checkResult_NNN(
							PicturePreviewActivity.this, content);
					if (results3 != null
							&& !results3.getRetmsg().equals("null")) {
						// Log.i(TAG, "解析出来的数据:" + results3.getRetmsg());
						try {
							user = JSONUtils.getListByJsonString(
									results3.getRetmsg(), User.class);
							// imgShowModel =
							// JSONUtils.getEntityByJsonString(results.getRetmsg(),
							// ImgShowModel.class);
							// Message msg=new Message();
							// msg.what=7;
							// Bundle bun=new Bundle();
							// bun.putString("type", type);
							// msg.setData(bun);
							handler.sendEmptyMessage(8);
						} catch (Exception e) {
							// TODO Auto-generated catch block
							e.printStackTrace();
						}
					} else {

						// handler.sendEmptyMessage(3);
					}
				} else {

					// handler.sendEmptyMessage(1);
				}

			}
		});

	}

	/**
	 * 用户评论使用接口 提交方式GET
	 * 
	 * @param $uid
	 *            ;//评论者的id @param $buid;//被评论者的id
	 * @param $conId
	 *            ;//被评论的内容id @param $type ;// 被评论类型activity club humor_trends
	 *            photo photo_img record_article
	 * @param $content
	 *            ;//评论内容
	 */
	public void sendMessage(final String uid, final String buid,
			final String conId, final String type, final String contents) {
		MyThreadTool.fixedThreadPool.execute(new Runnable() {
			@Override
			public void run() {
				// Log.v(TAG, "" + "uid=" + uid + "&buid=" + buid + "&conId="
				// + conId + "&type=" + type + "&content=" + contents);
				String content = Utils.getRequest(Constants.BadiUrl
						+ "user_discuss?uid=" + uid + "&buid=" + buid
						+ "&conId=" + conId + "&type=" + type + "&content="
						+ contents);

				if (content != null) {
					// System.out.println("数据是：" + content);
					Results results = Utils.checkResult_NNN(
							PicturePreviewActivity.this, content);
					if (results != null && !results.getRetmsg().equals("null")) {
						// Log.i("cccc", "解析出来的数据:" + results.getRetmsg());
						try {

							if (results.isRet() == true) {
								handler.sendEmptyMessage(5);
							} else {
								handler.sendEmptyMessage(6);
							}
						} catch (Exception e) {
							// TODO Auto-generated catch block
							e.printStackTrace();
						}
					} else {
						handler.sendEmptyMessage(3);
					}
				} else {
					handler.sendEmptyMessage(1);
				}

			}
		});
	}

	/**
	 * 查看某个动态的评论列表---get(必需--配合语言)
	 * 
	 * @param $id
	 *            //(必需)需要查看的动态评论ID
	 * @param $type
	 *            //(必需)动态的类型---photo_img：图片，photo：相册，record_article：记录（记），
	 *            humor_trends:心情动态，club：俱乐部，activity：活动
	 * @param $disNum
	 *            //显示的一级评论数量
	 * @param $l
	 *            ;（必需）//zh-cn 为中文简体，zh-tw 中文繁体 en-us 英文
	 */
	private void ShowDisscuss(final String id, final String type,
			final String disNum, String l) {
		Utils.showPrgress(PicturePreviewActivity.this);
		MyThreadTool.fixedThreadPool.execute(new Runnable() {
			@Override
			public void run() {
				Map<String, Object> map = new HashMap<String, Object>();
				// String content = Utils.sendRequest(map, Constants.BadiUrl
				// + "friends");
				String l = Dialog
						.getSystemLanguageTypegy(PicturePreviewActivity.this);
				String content = Utils.getRequest(Constants.BadiUrl_1
						+ "commonality/showDisscuss?id=" + id + "&type=" + type
						+ "&disNum=" + disNum + "&l=" + l);
				// + "&page=" + page + "&pageNum=" + 10);
				// Log.v(TAG, "结果是1:" + content);
				if (content != null) {
					Results results = Utils.checkResult_NNN(
							PicturePreviewActivity.this, content);
					if (results != null && !results.getRetmsg().equals("null")) {
						// Log.v(TAG, "评论的结果是:" + results.getRetmsg());
						try {
							discuss = JsonUtil.getEntityByJsonString(
									results.getRetmsg(), Discuss.class);
							// Log.v(TAG, "解析成功");
							// showDisscuss=discuss.getDiscu().get(0);
							// activityReadingModel=JsonUtil.getEntityByJsonString(results.getRetmsg(),
							// ActivityReadingModel.class);
							handler.sendEmptyMessage(4);
						} catch (Exception e) {
							e.printStackTrace();
							// Log.v(TAG, "解失败");
							handler.sendEmptyMessage(4);
						}
					} else {

						handler.sendEmptyMessage(3);
					}
				} else {

					handler.sendEmptyMessage(1);
				}
			}
		});
	}

	@Override
	protected void onActivityResult(int requestCode, int resultCode, Intent data) {
		// TODO Auto-generated method stub

		if (requestCode == 1) {
			try {
				Resh(AllPhoto_Models.get(num_show - 1).getId());
			} catch (Exception e) {
				// TODO: handle exception
			}

		}

		if (requestCode == PGEditSDK.PG_EDIT_SDK_REQUEST_CODE
				&& resultCode == Activity.RESULT_OK) {

			PGEditResult editResult = PGEditSDK.instance().handleEditResult(
					data);
			// 获取编辑后的缩略图
			Bitmap thumbNail = editResult.getThumbNail();
			// 获取编辑后的⼤大图路径
			String resultPhotoPath = editResult.getReturnPhotoPath();

			Intent intent = new Intent(this,
					ModifiedImageInformationActivity.class);

			intent.putExtra("imgId", imgShowModel.getId());

			startActivity(intent);

			Toast.makeText(this,
					"Photo saved to:" + editResult.getReturnPhotoPath(),
					Toast.LENGTH_LONG).show();

		}

		if (requestCode == PGEditSDK.PG_EDIT_SDK_REQUEST_CODE
				&& resultCode == PGEditSDK.PG_EDIT_SDK_RESULT_CODE_CANCEL) {
			Toast.makeText(this, "Edit cancelled!", Toast.LENGTH_SHORT).show();
		}

		if (requestCode == PGEditSDK.PG_EDIT_SDK_REQUEST_CODE
				&& resultCode == PGEditSDK.PG_EDIT_SDK_RESULT_CODE_NOT_CHANGED) {
			Toast.makeText(this, "Photo do not change!", Toast.LENGTH_SHORT)
					.show();
		}

		// Resh(num_show-1);

	}

	// /**
	// * 查看某个动态的评论列表---get(必需--配合语言)
	// *
	// * @param $id
	// * //(必需)需要查看的动态评论ID
	// * @param $type
	// * //(必需)动态的类型---photo_img：图片，photo：相册，record_article：记录（记），
	// * humor_trends:心情动态，club：俱乐部，activity：活动
	// * @param $disNum
	// * //显示的一级评论数量
	// * @param $l
	// * ;（必需）//zh-cn 为中文简体，zh-tw 中文繁体 en-us 英文
	// */
	// private void ShowDisscuss(final String id, final String type,
	// final String disNum, String l) {
	// Utils.showPrgress(getActivity());
	// MyThreadTool.fixedThreadPool.execute(new Runnable() {
	// @Override
	// public void run() {
	// Map<String, Object> map = new HashMap<String, Object>();
	//
	// // String content = Utils.sendRequest(map, Constants.BadiUrl
	// // + "friends");
	// String l = Dialog.getSystemLanguageTypegy(getActivity());
	// String content = Utils.getRequest(Constants.BadiUrl_1
	// + "commonality/showDisscuss?id=" + id + "&type=" + type
	// + "&disNum=" + disNum + "&l=" + l);
	// System.out.println();
	// // + "&page=" + page + "&pageNum=" + 10);
	// Log.v(TAG, "结果是1:" + content);
	// if (content != null) {
	// Results results = Utils.checkResult_NNN(getActivity(),
	// content);
	// if (results != null && !results.getRetmsg().equals("null")) {
	// Log.v(TAG, "结果是:" + results.getRetmsg());
	// try {
	// discuss = JsonUtil.getEntityByJsonString(
	// results.getRetmsg(), Discuss.class);
	// // showDisscuss=discuss.getDiscu().get(0);
	// //
	// activityReadingModel=JsonUtil.getEntityByJsonString(results.getRetmsg(),
	// // ActivityReadingModel.class);
	// handler.sendEmptyMessage(4);
	// } catch (Exception e) {
	// e.printStackTrace();
	// }
	// } else {
	//
	// handler.sendEmptyMessage(3);
	// }
	// } else {
	//
	// handler.sendEmptyMessage(1);
	// }
	// }
	// });
	// }
	/**
	 * 点赞 接口名称 praise_operate 用户的点赞人的id 提交方式$GET
	 * 
	 * @param $uid
	 *            ;//点赞人的id
	 * @param $nid
	 *            ;//被操作内容的Id
	 * @param $nuid
	 *            ;//内容所属人id
	 * @param $type赞的类型
	 *            （record_article，club，humor_trends，，activity）
	 * @param hander
	 *            ;
	 * @param Success
	 *            ;成功
	 * @param defalt
	 *            ;失败
	 */
	public void dianzan(final Context context, final String uid,
			final String nid, final String nuid, final String type) {
		Utils.showPrgress(context);
		MyThreadTool.fixedThreadPool.execute(new Runnable() {

			@Override
			public void run() {

				String content = Utils.getRequest(Constants.BadiUrl
						+ "praise_operate?uid=" + uid + "&nid=" + nid
						+ "&nuid=" + nuid + "&type=" + type);
				// Log.v("ttt", "uid=" + uid + "nid=" + nid + "nuid=" + nuid
				// + "type=" + type);
				// System.out.println("数据是：" + content);
				if (content != null) {
					// System.out.println("数据是：" + content);
					Results results = Utils.checkResult_NNN(context, content);
					if (results != null && !results.getRetmsg().equals("null")) {
						// Log.i("aaa", "解析出来的数据:" + results.getRetmsg());
						try {
							Message msg = new Message();
							if (results.isRet() == true) {

								msg.what = 14;
							} else {
								msg.what = 15;
							}

							handler.sendMessage(msg);

						} catch (Exception e) {
							e.printStackTrace();
						}
					} else {
						handler.sendEmptyMessage(3);
					}
				} else {
					handler.sendEmptyMessage(1);
				}
			}
		});

	}

	/**
	 * activity/imgAuthority 0：举报
	 * 
	 * 1：删除+编辑
	 */
	private void getBianjiQuanXian(String imgId) {

		MyThreadTool.fixedThreadPool.execute(new Runnable() {

			@Override
			public void run() {
				// TODO Auto-generated method stub
				Map<String, Object> map = new HashMap<String, Object>();
				map.put("uid", Utils.getUid(PicturePreviewActivity.this));
				map.put("imgId", imgShowModel.getId());

				String invite_content = Utils.sendRequest(map,
						Constants.BadiUrl_1 + "activity/imgAuthority");
				// Log.v(TAG,""+invite_content);
				if (invite_content != null) {
					results = Utils.checkResult_NNN(
							PicturePreviewActivity.this, invite_content);
					if (results != null && !results.getRetmsg().equals("null")
							&& results.isRet() == true) {
						// Log.i(TAG, "解析图片权限的数据:" + results.getRetmsg());
						try {
							// imgAuthority = JSONUtils.getEntityByJsonString(
							// results.getRetmsg(), ImgAuthority.class);
							Message msg = new Message();
							msg.what = 16;
							Bundle bun = new Bundle();
							bun.putString("msg", results.getRetmsg());
							msg.setData(bun);
							handler.sendMessage(msg);
						} catch (Exception e) {
							// TODO Auto-generated catch block
							e.printStackTrace();
							handler.sendEmptyMessage(16);
						}
					} else {

						handler.sendEmptyMessage(3);
					}
				} else {

					handler.sendEmptyMessage(1);
				}
			}
		});
	}
}
